home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / SeeMovieRun 2.0 / Source / x_CQTApp.cp < prev    next >
Encoding:
Text File  |  1995-08-02  |  6.0 KB  |  245 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  x_CQTApp.cp
  3.  
  4.                 CQTApp "Lower-Layer" Application Class
  5.     
  6.     Copyright © 1995 Gregory Bonk for NewMedia Inc.. All rights reserved.
  7.  
  8.     Generated by Visual Architect™ 12:55 PM Wed, Aug 2, 1995
  9.  
  10.     This file is rewritten each time you generate code. You should not
  11.     make changes to this file; changes should go in the CQTApp.cp
  12.     file, instead.
  13.  
  14.     If you want to change how Visual Architect generates this file, you can
  15.     change the template for this file. It is "_App_cp" in the Visual Architect
  16.     Templates folder.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "x_CQTApp.h"
  21.  
  22. #include "CQTApp.h"
  23.  
  24. #include "References.h"
  25. #include "CQTDoc.h"
  26. #include <CBartender.h>
  27. #include <Commands.h>
  28. #include <CDesktop.h>
  29. #include <CFile.h>
  30. #include <CFWDesktop.h>
  31. #include <CList.h>
  32. #include <Packages.h>
  33. #include <TBUtilities.h>
  34. #include <TCLForceReferences.h>
  35.  
  36. #include "CAboutBox.h"
  37. #include "CQTDoc.h"
  38.  
  39. extern OSType        gSignature;            /* Creator for Application's files    */
  40. extern CBartender    *gBartender;        /* Manages all menus                */
  41. extern CDesktop        *gDesktop;            /* The visible Desktop                */
  42.  
  43. #define ALRTabout 500
  44.  
  45.  
  46. TCL_DEFINE_CLASS_M1(x_CQTApp, CApplication);
  47.  
  48. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  49.  
  50.  
  51. /******************************************************************************
  52.  Ix_CQTApp
  53.  
  54.         Initialize an Application.
  55.  ******************************************************************************/
  56.  
  57. void    x_CQTApp::Ix_CQTApp(short extraMasters, Size aRainyDayFund,
  58.                                     Size aCriticalBalance, Size aToolboxBalance)
  59.  
  60. {
  61.     IApplication(extraMasters, aRainyDayFund, aCriticalBalance, aToolboxBalance);
  62. }
  63.  
  64.  
  65. /******************************************************************************
  66.  SetUpFileParameters    {OVERRIDE}
  67.  
  68.     Specify the kinds of files your application opens
  69.  ******************************************************************************/
  70.  
  71. void x_CQTApp::SetUpFileParameters()
  72. {
  73.     CApplication::SetUpFileParameters();
  74.  
  75.         // File types as defined in CQTApp.h
  76.  
  77.     sfNumTypes = kNumFileTypes;
  78.     sfFileTypes[0] = kFileType1;
  79.     sfFileTypes[1] = kFileType2;
  80.     sfFileTypes[2] = kFileType3;
  81.     sfFileTypes[3] = kFileType4;
  82.     gSignature = 'QT∂m';
  83. }
  84.  
  85.  
  86. /******************************************************************************
  87.  SetUpMenus {OVERRIDE}
  88.  
  89.         Set up the menus after first creating any floating/tearoff
  90.         windows. The latter must be done before the bartender inits.
  91.  ******************************************************************************/
  92.  
  93. void x_CQTApp::SetUpMenus()
  94. {
  95.  
  96.     CApplication::SetUpMenus();
  97. }
  98.  
  99.  
  100. /******************************************************************************
  101.  ForceClassReferences    {OVERRIDE}
  102.  
  103.     Reference classes that might do object I/O.
  104.  ******************************************************************************/
  105.  
  106. void x_CQTApp::ForceClassReferences(void)
  107.  
  108. {
  109.     CApplication::ForceClassReferences();
  110.  
  111.                                             /* From References.c            */
  112.     ReferenceStdClasses();                    /*     See template file Ref        */
  113.     
  114. }
  115.  
  116.  
  117. /**** C O M M A N D   M E T H O D S ****/
  118.  
  119.  
  120. /******************************************************************************
  121.  DoCommand    {OVERRIDE}
  122.  
  123.     Handle application commands
  124.  ******************************************************************************/
  125.  
  126. void x_CQTApp::DoCommand(long theCommand)
  127.  
  128. {
  129.     switch (theCommand)
  130.     {
  131.         case cmdAbout:
  132.  
  133.                 // Simple About alert. Subclasses will probably
  134.                 // trap this command to do something sexier.
  135.  
  136.             PositionDialog('ALRT', ALRTabout);
  137.             InitCursor();
  138.             ParamText("\pCQTApp", "\pGregory Bonk for NewMedia Inc.", "\p", "\p");
  139.             Alert(ALRTabout, NULL);
  140.             break;
  141.  
  142.         default:
  143.             CApplication::DoCommand(theCommand);
  144.             break;
  145.     }
  146. }
  147.  
  148.  
  149. /**** D O C U M E N T   M E T H O D S ****/
  150.  
  151.  
  152. /******************************************************************************
  153.  CreateDocument    {OVERRIDE}
  154.  
  155.     Make a new document when user chooses New from file menu.
  156.     This method is entirely generic except for the document class.
  157.  ******************************************************************************/
  158.  
  159. void x_CQTApp::CreateDocument()
  160.  
  161. {
  162.     CDocument    *volatile theDocument = NULL;
  163.  
  164.     theDocument = TCL_NEW(CQTDoc,());
  165.     TRY
  166.     {
  167.         ((CQTDoc*) theDocument)->ICQTDoc();
  168.         theDocument->NewFile();
  169.     }
  170.     CATCH
  171.     {
  172.         TCLForgetObject(theDocument);
  173.     }
  174.     ENDTRY
  175. }
  176.  
  177.  
  178. /******************************************************************************
  179.  OpenDocument    {OVERRIDE}
  180.  
  181.     Open a document when user chooses Open from file menu.
  182.     For multiple document types, this method assumes that each
  183.     document is associated with a single file type. 
  184.  ******************************************************************************/
  185.  
  186. void x_CQTApp::OpenDocument(SFReply *macSFReply)
  187.  
  188. {
  189.     CDocument    *volatile theDocument = NULL;
  190.  
  191.     theDocument = TCL_NEW(CQTDoc,());
  192.     TRY
  193.     {
  194.         ((CQTDoc*) theDocument)->ICQTDoc();
  195.         theDocument->OpenFile(macSFReply);
  196.     }
  197.     CATCH
  198.     {
  199.         TCLForgetObject(theDocument);
  200.     }
  201.     ENDTRY
  202. }
  203.  
  204.  
  205.  
  206.  
  207. /******************************************************************************
  208.  FileAlreadyOpen
  209.  
  210.     If file already in use return TRUE and bring owning document's
  211.     window to the foreground.  Sent from document before opening.
  212.  ******************************************************************************/
  213.  
  214.     static Boolean EqualFile(CDirector *obj, long param)
  215.     {
  216.         FSSpec        theFileSpec;
  217.         CFile        *theFile;
  218.         FSSpec        *theParam = (FSSpec*) param;
  219.  
  220.         if (member(obj, CDocument))
  221.         {
  222.             theFile = ((CDocument*)obj)->itsFile;
  223.             if (theFile == NULL)
  224.                 return FALSE;
  225.             theFile->GetFSSpec(&theFileSpec);
  226.             return theFileSpec.vRefNum == theParam->vRefNum
  227.                 && theFileSpec.parID == theParam->parID
  228.                 && !IUEqualString(theFileSpec.name, theParam->name);
  229.         }
  230.         return FALSE;
  231.     }
  232.  
  233. Boolean x_CQTApp::FileAlreadyOpen(
  234.     FSSpec        *fileSpec)
  235.  
  236. {
  237.     CDirector    *theDirector = NULL;
  238.  
  239.     if (itsDirectors)                        /* Search for matching file        */
  240.         theDirector = (CDirector*) itsDirectors->FindItem1(EqualFile, (long) fileSpec);
  241.     if (theDirector)                        /* If find one, bring to front    */
  242.         theDirector->GetWindow()->Select();
  243.     return theDirector != NULL;                /* Tell caller                    */
  244. }
  245.